﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using blackhouse.BlackApart.Business.Reservations;
using System.Globalization;

namespace blackhouse.BlackApart.Business.MailTemplate {
	public class ImpMailTemplate : IMailTemplate {

		#region Properties

		public int Id { get; set; }
		public string MailTitle { get; set; }
		public string TemplateControl { get; set; }
		public DateTime LastUpdateTime { get; set; }

		#endregion

		#region Methods

        public string GetMailTemplateUrlForReservation(IWebReservation reservation) {
			string mailGeneratorUrl = ConfigurationManager.AppSettings["MailGeneratorUrl"];
			string folder = Factory.Instance().GetPreFolderEvaluation();
			if (!string.IsNullOrEmpty(folder) && !folder.EndsWith("/"))
				folder = folder + '/';
			return string.Format(mailGeneratorUrl, reservation.ReservationId, this.Id, reservation.Guid, folder).ReplaceEx("*", "&"); // wstawienie & do web.config jest niedozwolone, stąd zamiana * na &.
		}

		#endregion

	}
}
